<?php
/**
 * 获取
 *
 *
 */

use Workerman\Worker;
use Workerman\Mysql;

class get_user_data{

    public function entry($param){
        //var_dump($param);
        return $this->do_get_user_data($param);
    }


    /**
     * do_set_poster_contents
     *
     *
     * @access private
     * @param $param
     * @since 1.0
     * @return array(errcode,errmsg,rtv)
     */
    private function do_get_user_data($param){
       // var_dump($param);die;
        //var_dump($_SERVER['HTTP_ACCESS_TOKEN']);die;
        $userObj= Token::getToken($_SERVER['HTTP_ACCESS_TOKEN']);
        //var_dump($userObj);die;
        $groups_id = $userObj['data']['user_data'][0]['groups'];
        $sql = "SELECT * FROM hf_mes_groups WHERE id='$groups_id'";
        $ret = sql_query($sql);
        if($ret[0]['class'] == '采购员'){
            $ret[0]['class_level'] = 1;
        }elseif ($ret[0]['class'] == '副总监'){
            $ret[0]['class_level'] = 2;
        }elseif ($ret[0]['class'] == '总监'){
            $ret[0]['class_level'] = 3;
        }elseif ($ret[0]['class'] == '设计师'){
            $ret[0]['class_level'] = 0;
        }


        return array("errcode"=>0, "errmsg"=>"", "rtval"=>$ret);

    }


    /**
     * create
     * 通过 call_user_func 获得本class的实例
     *
     * @access public
     * @since 1.0
     * @return object 本类的实例
     */
    public static function create(){
        static $instance;
        if (!$instance){
            $instance = new get_user_data();
        }
        return $instance;
    }
}


?>